<template>
    <div>
      <template v-for="item in this.menuList">
        <!--对应一个菜单项-->
        <el-submenu :disabled="item.disabled" :index="item.id+''" :key="item.id+''" v-if="item.children.length>0">
          <!--菜单栏名字-->
          <template slot="title">
            <i :class="item.icon"></i>
            <span slot="title">{{item.menuName}}</span>
          </template>
          <!--菜单栏内容-->
          <MenuTree :menuList="item.children"></MenuTree>
        </el-submenu>
        <el-menu-item
          v-else
          :disabled="item.disabled"
          :open="item.open"
          :index="item.url+''"
          :route="item.url+''"
          :key="item.id"
          @click="savePath(item.url)"
          style="padding-left: 50px"
        >
          <i :class="item.icon"></i>
          <span slot="title">{{ item.menuName }}</span>

        </el-menu-item>
      </template>
    </div>
</template>

<script>
    export default {
        name: "MenuTree",
        props:["menuList"],
        methods :{
          //保存激活路径
          savePath(path) {
            window.sessionStorage.setItem("activePath", path);
            //调用main.vue的activePath
            this.activePath = path;
          },
        },
    }
</script>

<style lang="less" scoped>

  /*移除处理*/
  .el-menu--collapse span,
  .el-menu--collapse i.el-submenu__icon-arrow {
    height: 0;
    width: 0;
    overflow: hidden;
    visibility: hidden;
    display: inline-block;
  }

</style>
